var express = require("express");
var router = express.Router();
const Result = require("../utils/result");
const sportsService = require("../services/sportsService");

// 搜索运动
router.get("/search", async function (req, res) {
  const { value } = req.query;
  const search = await sportsService.search(value);
  res.json(Result.success(search));
});

// 获取常用和收藏
router.get("/oftenAndCollect", async function (req, res) {
  const userId = req.query.userId;
  const { oftenUseArr, collectArr } = await sportsService.getOftenAndCollect(
    userId
  );
  res.json(Result.success({ oftenUseArr, collectArr }));
});

module.exports = router;
